package a;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		File file;
		int blockSize = 0;
		if(args.length == 0) {
			file = new File("E:\\Users\\Savva\\TSD\\allLab1\\testFile");
			blockSize = 500;
		} else {
			file = new File(args[0]);
			blockSize = Integer.valueOf(args[1]);
		}
		FileOutputStream fout = null;
		try {
			fout = new FileOutputStream(file);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
		byte[] bs = new byte[blockSize];
		for(int i = 0; i <blockSize - 1; i++) {
			byte[] b = ByteBuffer.allocate(4).putInt(i).array();
			if(i + 4 >= blockSize)
				break;
			for(int j = 0; j < b.length; j++) {
				i +=j;
				bs[i] = b[j];
			}
		}
		try {
				fout.write(bs);
				fout.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
